package com.example.yiqiuser.controller;


import com.example.yiqiuser.entity.Pic;
import com.example.yiqiuser.service.PicService;
import com.example.yiqiuser.util.Page;
import com.example.yiqiuser.util.Result;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @ fileName:PicController
 * @ description:
 * @ author:诸葛龙辰
 * @ createTime:2023/3/29 15:04
 * @ version:1.0.0
 */
@RestController
@RequestMapping("pic")
public class PicController extends BaseController{
    //依赖注入
    @Resource
    private PicService picService;

    /**
     * 分页带参查询
     * @param page
     * @return
     */
    @PostMapping("queryPage")
    public Result queryPage(@RequestBody Page<Pic> page){
        return success(picService.queryPage(page));
    }

    /**
     * 根据编号查询
     * @param id
     * @return
     */
    @GetMapping("queryById")
    public Result queryById(Integer id){
        return success(picService.queryById(id));
    }

    /**
     * 添加
     * @param pic
     * @return
     */
    @PostMapping("add")
    public Result add(@RequestBody Pic pic){
        return success(picService.add(pic));
    }

    /**
     * 更新
     * @param pic
     * @return
     */
    @PostMapping("update")
    public Result update(@RequestBody Pic pic){
        return success(picService.update(pic));
    }

    /**
     * 根据编号删除
     * @param pic
     * @return
     */
    @PostMapping("deleteById")
    public Result deleteById(@RequestBody Pic pic){
        return success(picService.deleteById(pic));
    }
}
